<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <div id="app">
        <button @click="sub">-</button>
        <span>{{number}}</span>
        <button @click="add">+</button>
    </div>

    <script src="./lib/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                number: 1
            },
            methods: {
                sub: function () {
                    // alert("-")
                    if (this.number <= 0) {
                        return alert("减不了了，大哥");
                    }
                    this.number--;

                },
                add: function () {
                    // alert("+")
                    if (this.number >= 10) {
                        return alert("土豪，少买一点吧");
                    }
                    this.number++;
                },

            }
        })
    </script>

</body>

</html>